#ifndef DTKSERIALPORT_H
#define DTKSERIALPORT_H

#include <QWidget>
#include <QtSerialPort/QSerialPort>
#include <QSerialPortInfo>
#include <QDateTime>
#include <QFile>
#include <QGridLayout>
#include <QThread>
#include <QMainWindow>
#include <QGroupBox>
#include <QComboBox>
#include <QPushButton>
#include <QCheckBox>
#include <QTextEdit>

#include "serialtx.h"
#include "serialman.h"
#include <QElapsedTimer>
#include <QTimer>

typedef enum {
    HexMode, AsciiMode,
}SerialTextMode_t;

typedef struct SerialConfig
{
    SerialTextMode_t    txmode;
    SerialTextMode_t    rxmode;
    
}SerialConfig_t;

class MainWindow : public QMainWindow
{
    Q_OBJECT
public:
    MainWindow(QMainWindow *parent = nullptr);
    ~MainWindow();

private:
    QWidget* w = new QWidget(this);

    SerialConfig_t* s_conf;

    QGroupBox*      CreateSerialSetting();
    QGroupBox*      CreateSendSetting();
    QGroupBox*      CreateRecvSetting();
    QGridLayout*    CreateTxRxLayout();

    QComboBox*      m_serialportbox;
    QPushButton*    m_sendbtn;
    QTextEdit*      m_sendtext;

    int             cycle_send_period;
    QTimer*         send_tm;

    SerialManager*  serial;

private slots:
    void            SerialBoxRefresh(const QStringList&);

signals:
    void            SingleTx(const QByteArray& msg);

};



#endif // DTKSERIALPORT_H
